package com.easyui.bean;

import java.util.List;
import java.util.Map;

import com.easyui.common.SelProject;

public class Student {
	private String sno;
	private String sname;
	private String sex;
	private String major;
	private String grade;
	private String stype;//学生的类型
	private List<Integer> proNum;//参与项目数
	
	public Student(){}
	
	/**
	 * 初始化学生信息
	 * @param sno
	 * @param sname
	 * @param sex
	 * @param major
	 * @param grade
	 * @param stype
	 */
	public Student(String sno, String sname, String sex, String major, String grade, String stype) {
		if(sno != null && !sno.trim().equals("")) {
			this.sno = sno.trim();
		} else {
			this.sno = sno;
		}
		
		if(sname != null && !sname.trim().equals("")) {
			this.sname = sname.trim();
		} else {
			this.sname = sname;
		}
		
		if(sex != null && !sex.trim().equals("")) {
			if(sex.trim().equals("all")) {
				this.sex = "";
			} else {
				this.sex = sex.trim();
			}
		}
		
		if(major != null && !major.trim().equals("")) {
			this.major = major.trim();
		} else {
			this.major = major;
		}
		
		if(grade != null && !grade.trim().equals("")) {
			this.grade = grade.trim();
		} else {
			this.grade = grade;
		}
		
		if(stype != null && !stype.trim().equals("")) {
			if(stype.trim().equals("all")) {
				this.stype = "";
			} else {
				this.stype = stype.trim();
			}
		}
		
	}
	
	/**
	 * 将Map对象转换成Student对象
	 * @param map
	 */
	public void init(Map map) {
		String sex = (String)map.get("sex");
		String stype = (String)map.get("stype");
		
		/*if(sex.equals("female")) {
			this.sex = "女";
		} else {
			this.sex = "男";
		}
		
		if(stype.equals("designer")) {
			this.stype = "美工";
		} else if(stype.equals("frontend")) {
			this.stype = "前端";
		} else {
			this.stype = "后台";
		}*/
		
		this.setSex(sex);
		this.setStype(stype);
		this.setSno((String)map.get("sno"));
		this.setSname((String)map.get("sname"));
		this.setSex(this.sex);
		this.setMajor((String)map.get("major"));
		this.setGrade((String)map.get("grade"));
		this.setStype(this.stype);
		this.setProNum(new SelProject().getProList(this.getSno()));
	}
	
	public List<Integer> getProNum() {
		return proNum;
	}

	public void setProNum(List<Integer> proNum) {
		this.proNum = proNum;
	}
	
	public String getSno() {
		return sno;
	}
	public void setSno(String sno) {
		this.sno = sno;
	}
	public String getSname() {
		return sname;
	}
	public void setSname(String sname) {
		this.sname = sname;
	}
	public String getSex() {
		return sex;
	}
	public void setSex(String sex) {
		this.sex = sex;
	}
	public String getMajor() {
		return major;
	}
	public void setMajor(String major) {
		this.major = major;
	}
	public String getGrade() {
		return grade;
	}
	public void setGrade(String grade) {
		this.grade = grade;
	}
	public String getStype() {
		return stype;
	}
	public void setStype(String stype) {
		this.stype = stype;
	}
	
}
